﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<TemplateWeb.Models.ViewModels.GroupViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Revenue
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent1" runat="server">
    <span class="AdminTitle" style="color:#cc0000;">Doanh thu Management</span>
	(<a href="<%= Url.Action("Index", "Home") %>" class="AdminPageText">
		<%= WebConfiguration.SiteName  %>
	</a>|
	<a href="<%= Url.Action("LogOff", "Account") %>" class="AdminPageText">
		LogOut
	</a>)
	<br />
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent2" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#Revenue_From").datepicker();
            $("#Revenue_To").datepicker();
            $("#Orders_NgayGiaoHang").datepicker();
        });

        function ValidateRevenue() {
            var from = document.getElementsByName("Revenue_From").item(0);
            if (from.value == "") {
                alert("Please input from");
                return false;
            }
            var to = document.getElementsByName("Revenue_To").item(0);
            if (to.value == "") {
                alert("Please input from");
                return false;
            }
            return true;
        }
	</script>
    <span class="AdminPageText">
    <% using (Html.BeginForm("Revenue", "Admin", FormMethod.Post, new { onsubmit = "return ValidateRevenue();" }))
       { %>
        Doanh thu từ ngày
        <input type="text" name="Revenue_From" id="Revenue_From" value="<%= Model.DonDatHangModel == null ? string.Empty : Model.DonDatHangModel.ReferKeys.From.ToShortDateString() %>" />
        Đến ngày
        <input type="text" name="Revenue_To" id="Revenue_To" value="<%= Model.DonDatHangModel == null ? string.Empty : Model.DonDatHangModel.ReferKeys.To.ToShortDateString() %>" />
        <input type="submit" name="sbt" id="sbt" value="Execute" style="background-image: url(../../Content/Images/Home/bgbutton.jpg); color: #FFFFFF; font-size: 16px; font-weight: bold; border: 1px #DBDBDB solid; height: 30px;" />
    <% } %>
        <br />
        <br />
    <% if(Model.DonDatHangModel != null)
       {
           var total = 0.0;
           foreach (var order in Model.DonDatHangModel.GetModel.LstObjModel)
           {
               foreach (var detail in order.ChiTietDonDatHang)
               {
                   total += (detail.SoLuong.Value * detail.Gia.Value);
               }
           }
    %>
        Tổng doanh thu: <span id="lblDoanhThu" style="font-weight: bold; color: Red"><%= string.Format("{0:0,0}", total)%> Đ</span>
        <br />
        <br />
        <div id="PartialDiv">
		    <% Html.RenderPartial("Templates/TH_EditOrdersRevenue", Model); %>
	    </div>
    <% } %>
    </span>
</asp:Content>
